package com.zk;

import org.I0Itec.zkclient.IZkDataListener;
import org.I0Itec.zkclient.ZkClient;

public class ListernNode {
    public static void main(String[] args) throws InterruptedException {
        ZkClient zkClient = new ZkClient("127.0.0.1:2181");
        zkClient.subscribeDataChanges("/country", new IZkDataListener() {
            @Override
            public void handleDataChange(String s, Object o) throws Exception {
                System.out.println(s);
                System.out.println(o);
            }

            @Override
            public void handleDataDeleted(String s) throws Exception {
                System.out.println("删除");
            }
        });

        zkClient.writeData("/country","##086");

        Thread.sleep(1000);

    }
}
